import MenuContext from '@/components/FlowDrawer/MenuContext/MenuContext.vue';
import {createApp, h} from 'vue';

export default {
  createMenuItem({top, left}, menuItems, onClick) {
    let div = document.createElement('div');
    document.body.appendChild(div);
    let res = h(MenuContext, {
      left, top, menuItems,
      onMenuItemClick: (item) => {
        if (onClick) {
          onClick(item);
        }
      },
      onClose() {
        div.remove();
      },
      expose: {
        close() {
          div.remove();
        },
      }
    })
    createApp(res).mount(div);
    return res
  },
};